package com.feiyun.util;

import java.util.UUID;

/**
 * @ClassName UUIDUtils
 * @author: xingming
 * @Description:
 * @time 2023/04/02 13:56:11
 * @Version 1.0
 */


public class UUIDUtils {

    public static String generate32UUID() {
        UUID uuid = UUID.randomUUID();
        String str = uuid.toString();
        // 去掉"-"符号
        String uuidStr = str.replace("-", "");
        return uuidStr;
    }

    public static String generate6UUID() {
        int hashCode = java.util.UUID.randomUUID().toString().hashCode();
        if (hashCode <0){
            hashCode=-hashCode;
        }
        // 0 代表前面补充0
        // 10 代表长度为10
        // d 代表参数为正数型
        String format = String.format("%06d", hashCode).substring(0,6);
        return format;
    }

}
